package com.aaa.doctor.controller;

import com.aaa.doctor.service.CareHistoryService;
import com.aaa.entity.CareHistory;
import com.aaa.entity.CareOrderItem;
import com.aaa.vo.Result;
import com.alibaba.fastjson.JSON;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @version 1.8.0_181
 * @Author ZXJ
 * @Date 2023/3/24 22:48
 * @注释
 */
@RestController
@RequestMapping("/doctor/carehistory")
public class CareHistoryController {
    @Autowired
    private CareHistoryService careHistoryService;
    /**
     *
     * 根据patientId查询患者的就诊信息
     * @param patientId
     * @return
     */
    @ApiOperation(value = "根据患者id查询患者病历信息")
    @PostMapping("/getPatientAllMessageByPatientId/{patientId}")
    public Result<List<CareHistory>> getPatientAllMessageByPatientId(@ApiParam(value = "患者id",required = true) @PathVariable String patientId){
        return careHistoryService.getPatientAllMessageByPatientId(patientId);
    }

    /**
     * 根据挂号单ID查询对应的病历信息
     * @param registrationId
     * @return
     */
    @PostMapping("/getCareHistoryByRegId/{registrationId}")
    @ApiOperation(value = "根据挂号单id查询病历单")
    public Result<List<CareHistory>> getCareHistoryByRegId(@ApiParam(value = "挂号单registrationId",required = true)@PathVariable String registrationId){
        return careHistoryService.getCareHistoryByRegId(registrationId);
    }


    /**
     * 根据registrationId保存病历
     * @param registrationId
     * @param careHistory
     * @return
     */
    @PostMapping("handleSaveCareHistory/{registrationId}")
    @ApiOperation(value = "新开就诊保存病历")
    public Result<CareHistory> handleSaveCareHistory(@PathVariable String registrationId,@RequestBody CareHistory careHistory){
        System.out.println("111111111111111111111"+careHistory);
        return careHistoryService.handleSaveCareHistory(registrationId,careHistory);
    }

    @GetMapping("zairu/{patientId}")
    public Result zairu(@PathVariable String patientId){
        return careHistoryService.zairu(patientId);
    }
}
